from rest_framework.views import APIView
from rest_framework.response import Response
import os
from qiniu import Auth
# 生成七牛云 token
class QiNiuToken(APIView):
    def get(self, request):
        name = "zkl0803"   # 空间名
        # access_key 与  secret_key  是七牛云的密钥
        auth = Auth(access_key='gnSsdULT46sRlADvfnciBdcKlzS_WAWRg4W6chte',
                    secret_key='zryZ79HIfXiXQQMi10hljQ5-tRr6UW2zENnbOwm9')
        token = auth.upload_token(name)
        return Response({'token': token})
